﻿@{
    ViewBag.Title = "List";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section mystyle{

}



@section myscript{
<script type="html/text" id="tpl-row">
    {{each ApiParamObj[0] as value i}}
    <tr>
        <td onclick="i_model('{{ value.ID }}')" class="weight">
            <span class="float-left padding-right-20">{{ value.TaskName }}</span>
            <span class="glyphicon glyphicon-search margin-left-5 margin-right-5 float-right green scale-pop-btn"></span>
        </td>
        <td>{{ value.PlanType }}</td>
        <td>{{ value.ITrainStartTime | dateFormat:'yyyy-MM-dd'}}</td>
        <td>
            {{ value.ITrainStartTime | dateFormat:'HH:mm' }}
            ~
            {{ value.ITrainEndTime | dateFormat:'HH:mm' }}
        </td>
        <td>{{ value.Brand }}</td>
        <td>
            {{if value.PerformState == 'SCHEDULED'}}
            <button class="btn btn-orange-line" type="button">已计划</button>
            {{else if value.PerformState == 'COMPLETE'}}
            <button class="btn btn-gray-line" type="button">已完成</button>
            {{else if value.PerformState == 'REJECT'}}
            <button class="btn btn-red-line" type="button">被驳回</button>
            {{/if}}
        </td>
    </tr>
    {{/each}}
</script>
    <script type="text/javascript">
      $.ajax({
        cache: false,
        async: false,
        url: '/api/CommonApi?API=CGetDictionarys',
        type: 'get',
        data: { Key: 'PLAN_TYPE,EXAMINE_WAY' },
        dataType: 'json',
        success: function (data) {
          if (data.Success) {
            Dictionarys = data.ApiParamObj;
            var doms = [$('#PlanType'), $('#Brand'), $('#PerformState')];
            for (var i = 0; i < data.ApiParamObj.length; i++) {
              var ApiParamObj = data.ApiParamObj[i];
              var html_li = '<li data-id="' + ApiParamObj.ID + '" data-value="' + ApiParamObj.Value + '" data-text="' + ApiParamObj.Text + '">' + ApiParamObj.Text + '</li>';
              var html_input = '<div class="inline-block margin-right-20">';
              html_input += '  <input class="none c-checkbox" type="checkbox" name="g1" id="c' + i + '" value="' + ApiParamObj.ID + '" />';
              html_input += '  <label for="c' + i + '" class="checkbox"></label>';
              html_input += '  <label for="c' + i + '">' + ApiParamObj.Text + '</label>';
              html_input += '  </div>';
              switch (ApiParamObj.Key) {
                case "PLAN_TYPE":
                  doms[0].append(html_li);
                  break;
                case '@user.Adjust[1]':
                  doms[1].append(html_li);
                  break;
                case 'ITRAIN_STATE':
                  doms[2].append(html_li);
                  break;
              }
            }
          }
        }
      });

        var initi_data = { sorts: ' CreateTime DESC', pagesize: 10, StartTime: '', EndTime: '', PlanType: '', Brand: '', PerformState: '', TaskName: '' };

        var page = new Corey_Page('CGetMyTasks', 'tpl-row', 'data-list', initi_data);

        var handle = {};
        handle.BindingCompleteAfter = function () {
            popbox.hide();
        }

        page.initList(1, handle);

        $('#search').click(function () {
            initi_data.StartTime = $('#StartTime').val();
            initi_data.EndTime = $('#EndTime').val();

            initi_data.PlanType = $('#S_PlanType').attr('data-text');
            initi_data.Brand = $('#S_Brand').attr('data-text');

            initi_data.PerformState = $('#S_PerformState').attr('data-value');
            initi_data.TaskName = $('#TaskName').val();
            page.initList(1, handle);
        });
    </script>
}